package cn.yhbk.web.modules.manager.Service.Impl;

import cn.yhbk.web.modules.manager.Pojo.DTO.Notice.TbNoticeDto;
import cn.yhbk.web.modules.manager.Pojo.Entity.TbNotice;
import cn.yhbk.web.modules.manager.Mapper.TbNoticeMapper;
import cn.yhbk.web.modules.manager.Pojo.VO.Notice.NoticePag;
import cn.yhbk.web.modules.manager.Service.ITbNoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 公告表 服务实现类
 * </p>
 *
 * @author 有何不可
 * @since 2023-08-05
 */
@Service
public class TbNoticeServiceImpl extends ServiceImpl<TbNoticeMapper, TbNotice> implements ITbNoticeService {

    @Autowired
    private TbNoticeMapper tbNoticeMapper;

    @Override
    public TbNoticeDto queryNoticeInfoById(Long id) {
        return tbNoticeMapper.queryNoticeInfoById(id);
    }

    @Override
    public NoticePag getNoticeInfoPag(Integer currentPage, Integer pageSize) {
        NoticePag noticePag = new NoticePag();
        noticePag.setPageSize(pageSize);
        noticePag.setCurrentPage(currentPage);
        noticePag.setTotalPage(tbNoticeMapper.queryTotalNum());
        noticePag.setNoticeList(tbNoticeMapper.queryNoticePage((currentPage - 1) * pageSize, pageSize));
        return noticePag;
    }
}
